<script type="text/html" template>
<div class="layui-fluid" id="profile-update">
    <form class="layui-form" lay-filter="profile-update-form">
        <input type="text" name="id" class="brand-hide" value="{{d.params.id}}"/>
        <div class="layui-form-item">
            <label class="layui-form-label">姓名：</label>
            <div class="layui-input-block">
                <input type="text" name="teacherName" readonly class="layui-input" value="{{d.params.teacherName}}">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">教师编号：</label>
            <div class="layui-input-block">
                <input type="text" name="teacherNum" readonly class="layui-input" value="{{d.params.teacherNum}}">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">手机：</label>
            <div class="layui-input-block">
                <input type="tel" name="teacherPhone" lay-verify="phone" autocomplete="off" class="layui-input" value="{{d.params.teacherPhone}}">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">邮箱：</label>
            <div class="layui-input-block">
                <input type="text" name="teacherEmail" lay-verify="email" maxlength="50" autocomplete="off"
                       class="layui-input"  value="{{d.params.teacherEmail}}">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label brand-form-item-require">性别：</label>
            <div class="layui-input-block">
                <input type="radio" name="teacherSex" value="1" title="男性" {{ d.params.teacherSex == 1 ? 'checked':''}}>
                <input type="radio" name="teacherSex" value="0" title="女性" {{ d.params.teacherSex == 0 ? 'checked':''}}>
            </div>
        </div>
        <div class="layui-form-item" id="area-picker">
            <div class="layui-form-label">地址</div>
            <div class="layui-input-inline" style="width: 200px;">
                <select name="teacherProvince" class="province-selector" lay-filter="province-1">
                    <option >请选择省</option>
                </select>
            </div>
            <div class="layui-input-inline" style="width: 200px;">
                <select name="teacherCity" class="city-selector" lay-filter="city-1">
                    <option >请选择市</option>
                </select>
            </div>
            <div class="layui-input-inline" style="width: 200px;">
                <select name="teacherDistrict" class="county-selector" lay-filter="county-1">
                    <option>请选择区</option>
                </select>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">详细地址</label>
            <div class="layui-input-block">
                <input type="text" name="teacherDetailaddr"  maxlength="50" autocomplete="off"
                       class="layui-input"  value="{{d.params.teacherDetailaddr||'无'}}">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">教师语录：</label>
            <div class="layui-input-block">
                <input type="text" name="teacherSayings" class="layui-input" value="{{d.params.teacherSayings}}">
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">简介：</label>
            <div class="layui-input-block">
                <textarea name="teacherDescription" maxlength="100" class="layui-textarea">{{d.params.teacherDescription}}
                </textarea>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button type="button" class="layui-btn" lay-submit lay-filter="submitInfo" id="submit">立即提交</button>
            </div>
        </div>
    </form>
</div>
</script>

<script data-th-inline="javascript">
    layui.use(['brand', 'form', 'validate', 'treeSelect','baseSetting'], function () {
        var $ = layui.$,
            brand = layui.brand,
            proPath = layui.baseSetting.brandConfig.proApi,
            setter = layui.setter,
            layer = layui.layer,
            treeSelect = layui.treeSelect,
            form = layui.form,
            user = layui.data(layui.setter.tableName)[layui.setter.USERNAME],
            $view = $('#profile-update'),
            validate = layui.validate;

        form.verify(validate);
        form.render();

        form.on('submit(submitInfo)', function (data) {
            console.log(data.field);
            brand.put(proPath + '/admin/teacher/updateSelfInfo', data.field, function (res) {
                if(res.status == '200'){
                    brand.flushUser();
                }else {
                    brand.alert.error(res.message)
                }
            });
            return false;
        });
    });
</script>